home *** CD-ROM | disk | FTP | other *** search
- /*
- * Hack to show how to use the viewer to make pictures. Click to quit.
- * nickt@apple.com
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- #include <StandardFile.h>
- #include <QuickDraw.h>
- #include <QDOffscreen.h>
- #include <Windows.h>
-
-
- #include "QD3DViewer.h"
-
-
- Boolean gQuitFlag = false;
- WindowPtr gMainWindow = nil ;
-
- void InitToolbox()
- {
- Handle menuBar = nil;
-
- MaxApplZone() ;
- MoreMasters() ; MoreMasters() ; MoreMasters() ;
-
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit() ;
- InitDialogs(0L) ;
- InitCursor();
-
- FlushEvents( everyEvent, 0 ) ;
- // initialize application globals
-
- gQuitFlag = false;
-
- }
-
- Boolean MetafileFileSpecify( FSSpec *theFile )
- {
- StandardFileReply theSFReply ;
- SFTypeList myTypes = { '3DMF' } ;
- const short numTypes = 1 ;
- OSErr myErr ;
-
-
- StandardGetFile( nil, numTypes, myTypes, &theSFReply ) ;
-
- if( theSFReply.sfGood )
- *theFile = theSFReply.sfFile ;
-
- return theSFReply.sfGood ;
-
- }
-
- void main(void)
- {
- TQ3Status myStatus;
- Rect rBounds = { 50, 50, 350, 350 } ;
- Str255 title = "\pSpinning Box" ;
- FSSpec theFileSpec ;
- OSErr myErr ;
- GWorldPtr myGWorld ;
-
- InitToolbox() ;
-
- if(MetafileFileSpecify( &theFileSpec )) {
- SetCursor(*(GetCursor(watchCursor)));
- gQuitFlag = false ;
- gMainWindow = NewCWindow(nil,&rBounds,title,false,noGrowDocProc,(WindowPtr)-1,true,0) ;
- SetWTitle( gMainWindow, theFileSpec.name );
- ShowWindow( gMainWindow ) ;
- SetPort( gMainWindow ) ;
-
- myErr = NewGWorld( &myGWorld,
- 32,
- &gMainWindow->portRect,
- nil,
- nil,
- 0L );
-
- SetCursor(&qd.arrow) ;
-
- if( myErr == noErr )
- {
- TQ3ViewerObject myViewer ;
- short refNum ;
-
-
- myViewer = Q3ViewerNew ( (CGrafPtr)myGWorld,
- &gMainWindow->portRect,
- kQ3ViewerDefault ) ;
-
- if( myViewer != NULL )
- {
- myErr = FSpOpenDF ( &theFileSpec, fsRdPerm, &refNum ) ;
- if( myErr == noErr )
- {
- PicHandle myPict = NULL ;
-
- Q3ViewerUseFile( myViewer, refNum ) ;
- SetPort( (GrafPtr)myGWorld ) ;
- Q3ViewerDraw( myViewer ) ;
- myPict = Q3ViewerGetPict( myViewer ) ;
-
- SetPort( gMainWindow ) ;
- DrawPicture( myPict, &gMainWindow->portRect ) ;
-
- while( !Button() )
- ;
- }
- }
- }
- }
- }
-
-